package com.baicun.wish.sink;


import com.univocity.parsers.csv.CsvWriter;
import com.univocity.parsers.csv.CsvWriterSettings;
import java.io.File;
import java.nio.charset.Charset;

/**
 * @author baicun
 * @description 爬取数据写入Csv文件中
 */
public class SinkToCsv {
    //Csv保存路径

    static String PATH = "Y:\\Projects\\IDEA\\development\\wish\\wish-data\\src\\main\\java\\com\\baicun\\wish\\csv\\";

    static CsvWriter csvwriter;

    public static void create(String filename){
        csvwriter = new CsvWriter(new File(PATH + filename), Charset.forName("UTF-8"),new CsvWriterSettings());
    }
    public static void writeHeader(String[] header){
        csvwriter.writeRow(header);
    }
    public static void writeContent(String[] content){
        csvwriter.writeRow(content);
    }
    public static void close(){
        // 关闭csvWriter
        csvwriter.close();
    }
}
